<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>绑定患者</title>
		<script src="../js/mui.min.js"></script>
		<link href="../css/mui.min.css" rel="stylesheet" />
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">绑定患者</h1>
		</header>
		<div class="mui-content">
			<p style="margin-top:20px;margin-left: 20px;">通过配对码绑定患者</p>
			
			<div class="mui-content-padded">
				<div class="mui-input-row">
					<label>配对码</label>
					<input type="text" class="mui-input-clear" id="pairCodeArea" placeholder="配对码区域">
				</div>
			</div>
			
			<div class="mui-button-row">
				<button type="button" onclick="bindPatient();" class="mui-btn mui-btn-primary" >绑定患者</button>
			</div>
			
			<div style="height:44px;"></div>
			
		</div>

		<script>
			mui.init();
			
			function bindPatient(){
				var userName = localStorage.getItem('userName');
				var pairCode = document.getElementById('pairCodeArea').value;
				//alert(userName + ' ' + pairCode);
				var url = localStorage.getItem('remoteAddress') + '/api/bindPatient';
				mui.post(url,{
					userName: userName,
					pairCode: pairCode
				},function(data){
					var data = data.data;
					//服务器返回响应，根据响应结果，分析是否登录成功；
					var pairSuccess = data.pairSuccess;
					if(pairSuccess == '1'){
						mui.toast('绑定成功');
						plus.webview.close('bindPatientPage');
					}else{
						mui.toast('配对码不存在或已经绑定');
					}
				},'json'
				);
			}
			
			

		</script>
	</body>
</html>
